package nyist.media.service.impl;

import nyist.media.entity.admin.Log;
import nyist.media.page.AppPage;
import nyist.media.repository.LogRepository;
import nyist.media.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

/**
 * @author : dcf
 * @date : 2019/3/15
 */

@Service
public class LogServiceImpl implements LogService {

    @Autowired
    private LogRepository logRepository;

    @Override
    public AppPage<Log> findLogs(PageRequest pageRequest, String keyword) {
        Page<Log> page = logRepository.findAll(pageRequest, keyword);
        return new AppPage<>(pageRequest, page.getTotalElements(), page.getTotalPages(), page.getContent());
    }

    @Override
    public void deleteAll() {
        logRepository.deleteAll();
    }
}

